<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>教学管理——解密助手</title>
    <meta name="description" content="作者：逄沛然
学校：青岛第二实验初级中学">
    <meta name="keywords" content="教学管理,解密">
    <meta name="author" content="逄沛然">
    <meta property="og:title" content="教学管理——解密助手">
    <meta property="og:description" content="作者：逄沛然
学校：青岛第二实验初级中学">
    <meta name="twitter:card" content="summary">
    <meta name="twitter:title" content="教学管理——解密助手">
    <meta name="twitter:description" content="作者：逄沛然
学校：青岛第二实验初级中学">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="css/base/jquery-ui.min.css" rel="stylesheet">
    <link href="css/de_index.css?v=12" rel="stylesheet">
    <script src="js/jquery-3.6.0.min.js"></script>
    <script src="js/jquery-ui.min.js"></script>
    <script>

   $(document).ready(function()
   {
      $("a[href*='#Frame']").click(function(event)
      {
         event.preventDefault();
         $('html, body').stop().animate({ scrollTop: $('#Frame').offset().top }, 600, 'linear');
      });
      $("#PictureUpload :file").on('change', function()
      {
         var input = $(this).parents('.input-group').find(':text');
         input.val($(this).val());
      });
      $("#Tabs").tabs(
      {
         show: { effect: 'slide', direction: 'left', duration: 300, easing: 'swing' },
         hide: { effect: 'slide', direction: 'right', duration: 300, easing: 'swing' },
         event: 'click',
         collapsible: false
      });
      $("#Tabs").on('tabsactivate', function(event, ui)
      {
         var indexNew = $(this).find('li').index(ui.newTab);
         switch(indexNew)
         {
               case 0:
                  if (document.getElementById("PictureUpload-input").value.length > 0) str = document.getElementById('Picture').childNodes[1].childNodes[3].src;;
                  break;
               case 1:
                  str = document.getElementById('PlainText').value;;
                  break;
         }
      });
   });
    </script>
    <script src="./js/en_decryption.js"></script>
    <script>

   function decryption() {
       let alls = document.getElementById('CipherText').value;

       let arr = alls.split(" ");
       let key1 = arr[0];
       let key2 = arr[1];
       let ciphertext = arr[2];

       let notice = "解密成功！";
       if (unixTime() >= Number(key1)) {
           let plaintext = ed_decryption(key1, key2, ciphertext);
           if (plaintext.substring(0, 11) === 'data:image/') {
               document.getElementById('TextArea1').style.display = "none";
               document.getElementById('Image').style.display = "";
               document.getElementById('Image').src = plaintext;
           }
           else {
               document.getElementById('Image').style.display = "none";
               document.getElementById('TextArea1').style.display = "";
               document.getElementById('TextArea1').value = plaintext;
           }
       }
       else {
           document.getElementById('Image').style.display = "none";
           document.getElementById('TextArea1').style.display = "";
           document.getElementById('TextArea1').value = '未到解密时间，禁止解密！';
           notice = '解密失败，还剩 ';

           let cnt = 0;
           let left = Number(key1) - unixTime();
           if (left > 60) {
               ++cnt;
               left = left / 60.0;
               if (left > 60) {
                   ++cnt;
                   left = left / 60.0;
                   if (left > 24) {
                       ++cnt;
                       left = left / 24.0;
                   }
               }
           }

           notice += String(left);
           if (cnt == 0) {
               notice += " 秒";
           }
           else if (cnt == 1) {
               notice += " 分钟";
           }
           else if (cnt == 2) {
               notice += " 小时";
           }
           else {
               notice += " 天";
           }
       }

       document.getElementById('Notice').value = notice;
   }
    </script>
</head>
<body>
    <div id="Frame">
        <div class="TOP">
            <div id="wb_Heading1">
                <h1 id="Heading1">教学管理——解密助手</h1>
            </div>
        </div>
        <div class="TEXT">
            <textarea name="CipherText" id="CipherText" rows="5" cols="116" spellcheck="false"></textarea>
        </div>
        <div class="NOTICE">
            <input type="text" id="Notice" name="Notice" value="" readonly spellcheck="false">
        </div>
        <div class="BUTTON">
            <a id="Button" href="javascript:void(0);" onclick="decryption();return false;">解密</a>
        </div>
        <div class="DIV">
            <div id="wb_Image">
                <img src="" id="Image" alt="">
            </div>
            <textarea name="TextArea1" id="TextArea1" rows="19" cols="116" readonly spellcheck="false" title="PlainText">请在上方输入并解密</textarea>
        </div>
        <div class="BOTTOM">
            <div id="wb_Heading2">
                <h1 id="Heading2"><br><center><b>操作说明</b></center><br><center>一、操作步骤</center>一、在上方文本框中输入（建议粘贴）加密后的内容；<br>二、点击“解密”按钮；<br>三、若时间已到，则可以正常解密；否则会有错误提示。<br><br><center>二、错误提示</center>一、到解密时间且无法解密：请检查密文是否出错。<br>二、解密成功但内容明显错误、乱码：请检查是否修改过密文，如果没有，请联系管理员重新加密。<br><br>作者：逄沛然<br>学校：青岛第二实验初级中学</h1>
            </div>
        </div>
    </div>
</body>
</html>